<template>
  <div>

    <van-field label='名称' v-model='form.name'/>

    <h1>头像</h1>
    <van-image :src="pic" width="150" height="150"/>
    <van-uploader :after-read="afterRead"/>


    <h1>视频</h1>
    <van-uploader :after-read="vedio_upload"/>
    <video :src="'http://localhost:5000/'+form.video_url" controls="controls" width="236" height="160"
           v-if="form.video_url"></video>


    <br>
    <van-button @click="add">添加</van-button>

  </div>
</template>

<script>
export default {
  name: "vedio",
  data() {
    return {
      form: {'video_url': ''},
      pic: 'http://localhost:5000/static/upload/',
      filelist: [],
    }
  },

  methods: {
    afterRead(file) {
      let data = new FormData
      data.append('file', file.file)
      this.axios.post('jpgupload', data).then(res => {
        this.pic = 'http://localhost:5000/static/upload/' + res.data.pic
      })
    },
    vedio_upload(file) {
      let formdata = new FormData()
      formdata.append('file', file.file)
      formdata.append('id', 1)
      this.axios.post('vedioupload', formdata).then(res => {
        this.form.video_url = res.data.url
        console.log(res)
      })
    },
    add() {
      this.axios.post('', this.form).then(res => {

      })
    }
  },

  mounted() {
  }
}
</script>

<style scoped>

</style>
